<template>
	<view v-if="list">
		<u-radio-group placement="column" v-model="rvalue">
			<view class="coupon-item" v-for="(item, index) in list" :key="index">
				
				<view class="coupon-icon">
					<u-icon name="coupon-fill" color="#ffd91d" size="45"></u-icon>
				</view>
				<view class="coupon-money">
					<block v-if="item.is_free == 1">
						<view :class="item.nid > 0 ? 'layof':'layof-name'">{{item.name}}</view>
					</block>
					<block v-else>
						<view class="layof" v-if="item.coupon_type == 10">￥{{item.reduce_price}}</view>
						<view class="layof" v-if="item.coupon_type == 20">{{item.discount_display}}折</view>
						<view class="layof" v-if="item.coupon_type == 30">{{item.discount_display}}折</view>
						<view class="layof" v-if="item.coupon_type == 40">{{item.name}}</view>
					</block>
					<view class="end_time" v-if="item.nid > 0">{{item.end_time}}前使用</view>

				</view>

				<view class="rd">
					<u-radio size="26" :key="index" @change="radioChange(item)" :name="item.nid" label="选中"></u-radio>
				</view>

			</view>
		</u-radio-group>
	</view>

</template>

<script>
	export default {
		props: {
			couponId: {
				type: String
			},
			list: {
				type: Array
			},

		},
		data() {
			return {
				rvalue: this.couponId
			}
		},
		watch: {
			couponId() {
				this.rvalue = this.couponId
			}
		},
		methods: {
			radioChange(item) {
				this.$emit('use', item)
			}
		}
	}
</script>

<style lang='scss'>
	.rd {}

	.coupon-item {
		margin: 0 20upx;
		padding: 10upx 0;
		width: 90%;
		border-radius: 10upx;
		margin-top: 40upx;
		/* border: 1px solid #eeeeee; */
		box-shadow: 0 4rpx 8rpx 0 rgba(0, 0, 0, 0.2), 0 6rpx 20rpx 0 rgba(0, 0, 0, 0.19);

		display: flex;
		align-items: center;
		justify-content: center;

		.coupon-icon {
			width: 100upx;
			float: left;
		}

		.coupon-money {
			width: 390upx;
			display: table;
			float: left;
			/* border-style: none dotted none none; */
			/* border-color: #eeeeee; */

			.nick {
				width: 100%;
				height: 50upx;
				line-height: 30upx;
				font-size: 24upx;
				color: #999999;
			}

			.tit {
				width: 100%;
				height: 50upx;
				line-height: 50upx;
				font-size: 24upx;
				color: #999999;
			}


			.layof {
				width: 100%;
				height: 42upx;
				line-height: 30upx;
				font-size: 42upx;
				color: #ffd91d;
				/* font-weight: bold; */
			}

			.layof-name {
				width: 100%;
				height: 42upx;
				line-height: 46upx;
				font-size: 42upx;
				color: #ffd91d;
				/* font-weight: bold; */
			}

			.end_time {
				width: 100%;
				/* 		height: 30upx; */
				line-height: 30upx;
				font-size: 24upx;
				color: #999999;
			}
		}
	}
</style>